Skip to content

Conversation

@apu031
Copy link

@apu031 apu031 commented Nov 19, 2025

Add support for HTTP/2 informational responses, enabling servers to send multiple 1xx status code responses before the final response and clients to receive them separately.

Key Features Added

Client-side Support

  • Add poll_informational() method to ResponseFuture for polling 1xx responses
  • Modify response polling logic to properly handle and skip informational headers
  • Ensure informational responses don't interfere with main response flow

Server-side Support

  • Add send_informational() method to SendResponse with documentation
  • Support multiple informational responses per request (e.g., 100 Continue, 103 Early Hints)
  • Validate that only 1xx status codes are sent as informational responses
  • Gracefully handle invalid informational responses without breaking the stream

Protocol Implementation

  • Add InformationalHeaders event type to distinguish from regular headers
  • Implement send_informational_headers_direct() for sending without state changes
  • Modify header processing to route informational responses correctly
  • Ensure informational responses don't affect HTTP/2 stream state transitions

Changed Files

  • Cargo.toml: Switch to local http crate dependency for extended status code support
  • src/client.rs: Add client-side informational response polling API
  • src/proto/streams/recv.rs: Implement informational header event handling and polling
  • src/proto/streams/send.rs: Add direct informational header sending capability
  • src/proto/streams/streams.rs: Integrate informational response methods into stream APIs
  • src/server.rs: Add server-side informational response API
  • tests/h2-tests/tests/informational_responses.rs: Add 6 unit tests
    * send_100_continue: Basic 100 Continue functionality
    * send_103_early_hints: 103 Early Hints with Link headers
    * send_multiple_informational_responses: Multiple 1xx responses in sequence
    * invalid_informational_status_returns_error: Invalid status code handling
    * client_poll_informational_responses: Client-side polling API
    * informational_responses_with_body_streaming: Streaming scenarios

Use Cases Supported

  • 100 Continue: Allow clients to continue sending request body
  • 103 Early Hints: Provide early resource hints for client preloading

Technical Notes

  • Informational responses are sent without the END_STREAM flag
  • Stream state remains unchanged when sending informational responses
  • Multiple informational responses can be sent before the final response
  • Client polling separates informational responses from the main response flow
  • Backward compatibility maintained - existing code continues to work unchanged

Resolves support for HTTP 103 Early Hints and 100 Continue HTTP/2 informational responses.

Copy link

@vikanezrimaya vikanezrimaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've run the tests and it seems to work, and the diff seems to make some sense to me, although I would like someone more familiar with Hyper to have a look at it.

However, I already see this could benefit from at least running rustfmt and fixing one doctest (details below). Also the commit messages should be changed to conform to the commit guidelines.

@apu031 apu031 force-pushed the http-103 branch 2 times, most recently from b7ec555 to 835bb8f Compare November 19, 2025 23:15
Copy link

@pablocm pablocm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My overall feedback:

  1. About naming/terminology: The RFC9110 I think we're conflating two related concepts: The word "Informational" defines the range of 1XX status codes, and "interim" is used to describe non-final responses. I think it would be conceptually clearer to use the latter to describe some of the logic, e.g. send_interim_headers instead of send_informational_headers_direct. Thoughts?
  2. Can you provide integration tests in tests/h2-tests/ showing example happy paths and also corner cases?

Full disclosure -- the author and I are work colleagues. I didn't participate in the coding but do have vested interested in seeing this feature merged.

@LPardue
Copy link
Contributor

LPardue commented Nov 20, 2025

FWIW, there is also a new 104 status code for resumable uploads being standardized, so you can consider that another use case: https://www.ietf.org/archive/id/draft-ietf-httpbis-resumable-upload-10.html#section-5

@apu031
Copy link
Author

apu031 commented Nov 20, 2025

FWIW, there is also a new 104 status code for resumable uploads being standardized, so you can consider that another use case: https://www.ietf.org/archive/id/draft-ietf-httpbis-resumable-upload-10.html#section-5

@LPardue for sure! The PRs are the backbone for the informational codes support for hyper. I will add 104 specific examples once 103 related code is merged.

@apu031 apu031 force-pushed the http-103 branch 2 times, most recently from 5cb42ff to 5963d0c Compare November 27, 2025 22:15
@apu031 apu031 force-pushed the http-103 branch 3 times, most recently from b043240 to 273fb77 Compare November 28, 2025 12:20
@apu031 apu031 force-pushed the http-103 branch 4 times, most recently from 90fecb8 to 3df7d53 Compare November 28, 2025 14:18
Add support for HTTP/2 informational responses (1xx status codes) including
103 Early Hints. This enables servers to send preliminary headers before
the final response, improving client performance through early resource
discovery and connection establishment.

Changes include:
- extend client and server APIs to handle interim informational responses
- update stream state management for 1xx responses
- add test for interim informational response scenarios

This implementation follows RFC 7540 and RFC 8297 specifications for
HTTP/2 informational responses handling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants